package be.tihh.mgmt.util;

import java.io.*;

public class StreamGobbler extends Thread {

    InputStream is;
    String type;

    public StreamGobbler(InputStream is, String type) {
        this.is = is;
        this.type = type;
    }

    public void run() {
        try {
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);

            String line;
            while ( (line = br.readLine()) != null){
                System.out.println(type + ">" + line);
            }

/*
            int value;
            while ((value=br.read())!=-1) {
                char c = (char) value;
                System.out.print(c);
            }
*/

            System.out.println("done reading " + type);

        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
